<template>
  <div style="padding: 20px">
    <el-form :data="search" style="width: 100%">
      <el-form-item label="已审核状态" prop="status">
        <el-select
          v-model="search.status"
          clearable
          placeholder="请选择商品状态"
          @change="handleQuery"
        >
          <el-option
            v-for="item in [
              {
                value: '1',
                label: '已通过',
              },
              {
                value: '3',
                label: '已驳回',
              },
            ]"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
    <right-toolbar @queryTable="get_list"></right-toolbar>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="id" width="120"> </el-table-column>
      <el-table-column prop="goodsId" label="goodsid" width="120">
      </el-table-column>
      <el-table-column prop="userId" label="用户" width="200">
      </el-table-column>
      <el-table-column prop="goods.title" label="盒子名称" width="200">
      </el-table-column>
      <el-table-column prop="goods.imgurl" label="封面" width="200">
        <template slot-scope="scope">
          <img
            :src="scope.row.goods.imgurl"
            style="width: 100px; height: 100px"
          />
        </template>
      </el-table-column>
      <el-table-column
        prop="goods.price"
        label="价格"
        width="120"
      ></el-table-column>
      <el-table-column prop="status" label="状态" width="120">
        <template slot-scope="scope">
          <el-tag :type="['', 'success', 'info', 'danger'][scope.row.status]">{{
            ["", "已通过", "待审核", "未通过"][scope.row.status]
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="message" label="审核意见"> </el-table-column>
      <el-table-column prop="createTime" label="日期"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="120">
        <template slot-scope="scope">
          <!-- <el-button
            @click.native.prevent="deleteRow(scope.$index, tableData)"
            type="text"
            size="small"
          >
            移除
          </el-button> -->
          <el-button
            @click.native.prevent="look(scope.row)"
            type="text"
            size="small"
          >
            查看详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="page.page"
      :limit.sync="page.pageSize"
      @pagination="get_list"
    />
  </div>
</template>

<script>
import { get_list } from "@/api/czz/index.js";
export default {
  name: "Czz/yi",
  data() {
    return {
      tableData: [],
      page: {
        page: 1,
        pageSize: 10,
      },
      loading: false,
      total: 0,
      search: {
        status: "1",
      },
    };
  },
  methods: {
    handleQuery() {
      this.get_list();
    },

    get_list() {
      this.loading = true;

      get_list({
        page: this.page.page,
        pageSize: this.page.pageSize,
        ...this.search,
      }).then((res) => {
        this.loading = false;
        this.tableData = res.data.list;

        if (this.search.status == 3) {
          //筛选掉无messge的数据
          this.tableData = this.tableData.filter((item) => {
            return item.message;
          });
        }

        this.total = res.data.total;
      });
    },
    handleSizeChange(val) {
      this.page.limit = val;
      this.get_list();
    },
    handleCurrentChange(val) {
      this.page.page = val;
      this.get_list();
    },
    handleSearch() {
      this.page.page = 1;
      this.get_list();
    },
    handleReset() {
      this.search = {
        status: 0,
      };
      this.get_list();
    },

    //查看详情
    look(row) {
      const tableId = row.goodsId;
      const tableName = row.title;
      //   const params = { pageNum: this.queryParams.pageNum };
      console.log(row);

      this.$tab.openPage(
        "查看待审核[" + tableName + "]盒子商品详情",
        "/czz/goods_xq/index/" + tableId
      );
    },
  },
  mounted() {
    this.get_list();
  },
};
</script>

<style></style>
